package com.yyk.dzvisit.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.yyk.dzvisit.enums.BizErrorEnum;
import com.yyk.dzvisit.exception.BusinessException;
import com.yyk.dzvisit.model.dto.req.TokenReq;
import com.yyk.dzvisit.model.dto.req.app.RecordReturnResultReq;
import com.yyk.dzvisit.model.dto.req.app.UserLoginReq;
import com.yyk.dzvisit.model.dto.resp.GetNotReturnResp;
import com.yyk.dzvisit.model.dto.resp.GetYesReturnResp;
import com.yyk.dzvisit.model.dto.resp.UserLoginInfoResp;
import com.yyk.dzvisit.service.WorkService;
import com.yyk.dzvisit.service.his.HISBusinessService;
import com.yyk.dzvisit.util.BeanUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Slf4j
@Service
public class WorkServiceimpl implements WorkService {

    @Autowired
    private HISBusinessService hisBusinessService;

    @Override
    public UserLoginInfoResp getUserLoginInfo(UserLoginReq userLoginReq) {
        String username = userLoginReq.getUsername();
        String password = userLoginReq.getPassword();

        //调用his接口查询该医生信息
        JSONObject jsonObject =hisBusinessService.his3013(username, password);
        if(jsonObject==null){
            throw new BusinessException(BizErrorEnum.HIS_BIZ_EXCEPTION,"未查询到用户信息");
        }
        //可以根据工具快速json转bean
        UserLoginInfoResp userLoginInfoResp = BeanUtil.copyPropertiesByFastJson(jsonObject, UserLoginInfoResp.class);
        return userLoginInfoResp;
    }

    @Override
    public List<GetNotReturnResp> getNotReturn(TokenReq tokenReq) {
        return null;
    }

    @Override
    public List<GetYesReturnResp> getYesReturn(TokenReq tokenReq) {
        return null;
    }

    @Override
    public void recordReturnResult(RecordReturnResultReq recordReturnResultReq) {

    }
}
